Counting and Randomly Generating Binary Trees

نویسنده

  • James F. Korsh
چکیده

The number b, of binary trees with n nodes is well known. Two ways to determine b, are presented in [3]. One, based on constructing them, leads to recurrence relations solved by generating functions. The other recognizes that b, is the same as the number of stack permutations and counts these permutations. In [l], a method based on well-formed sequences of parentheses is given, and the result is applied to generating a random binary tree in linear time using integers of size no larger than 2n. Enumeration of binary trees is done in [2,5-71. In this paper a simple direct approach is used to find b,. It aIso provides another way to generate a random binary tree as efficiently as in [l]. In [41 this approach gives ranking and unranking algorithms as efficient as those in [7], and allows a more efficient algorithm to determine the next binary tree. For any n > 0, a binary tree with n nodes can be uniquely represented by a sequence of n pairs of O’s and l’s, one pair for each node. In a node’s pair, x y, x (y> specifies whether the node’s left (right) subtree is null or non-null: 0 for null and 1 for non-null. The pairs appear in the order in

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Bounding Right-Arm Rotation Distances

Rotation distance quantifies the difference in shape between two rooted binary trees of the same size by counting the minimum number of elementary changes needed to transform one tree to the other. We describe several types of rotation distance, and provide upper bounds on distances between trees with a fixed number of nodes with respect to each type. These bounds are obtained by relating each ...

متن کامل

Pattern avoidance in binary trees

This paper introduces the notion of pattern avoidance in binary trees. We provide an algorithm for computing the generating function that counts the number of n-leaf binary trees avoiding a given binary tree pattern t. Equipped with this counting mechanism, we study the analogue of Wilf equivalence in which two tree patterns are equivalent if the respective trees that avoid them are equinumerou...

متن کامل

Spanning Tree Size in Random Binary Search Trees

This paper deals with the size of the spanning tree of p randomly chosen nodes in a binary search tree. It is shown via generating functions methods, that for fixed p, the (normalized) spanning tree size converges in law to the Normal distribution. The special case p = 2 reproves the recent result (obtained by the contraction method by Mahmoud and Neininger [Ann. Appl. Probab. 13 (2003) 253–276...

متن کامل

1 1 A pr 2 00 6 BOUNDING RIGHT - ARM ROTATION DISTANCES

Rotation distance measures the difference in shape between binary trees of the same size by counting the minimum number of rotations needed to transform one tree to the other. We describe several types of rotation distance where restrictions are put on the locations where rotations are permitted, and provide upper bounds on distances between trees with a fixed number of nodes with respect to se...

متن کامل

2 0 Ju n 20 05 BOUNDING RIGHT - ARM ROTATION DISTANCES

Rotation distance quantifies the difference in shape between two rooted binary trees of the same size by counting the minimum number of elementary changes needed to transform one tree to the other. We describe several types of rotation distance, and provide upper bounds on distances between trees with a fixed number of nodes with respect to each type. These bounds are obtained by relating each ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Inf. Process. Lett.

دوره 45  شماره 

صفحات  -

تاریخ انتشار 1993